package com.lz.commonlibrary.drawable;

import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;

/**
 * @author 黄赛赛
 * @version V1.0
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}()
 * @date 2016/5/16 18:41
 */
public class SelectorFactory {

/*    int[] stateSelectArr = new int[]{android.R.attr.state_checked, };
    int[] stateUnSelectArr = new int[]{-android.R.attr.state_checked, };*/
    public StateListDrawable getStateListSelector(int[] stateSelectArr, Drawable selectDrawable, int[] stateUnSelectArr, Drawable unSelectDrawable){
        StateListDrawable drawable = new StateListDrawable();
        drawable.addState(stateSelectArr, selectDrawable);
        drawable.addState(stateUnSelectArr, unSelectDrawable);
        return  drawable;
    }

    public StateListDrawable geCheckSelector(Drawable selectDrawable, Drawable unSelectDrawable){
        StateListDrawable drawable = new StateListDrawable();
        int[] stateSelectArr = new int[]{android.R.attr.state_checked, };
        int[] stateUnSelectArr = new int[]{-android.R.attr.state_checked, };
        drawable.addState(stateSelectArr, selectDrawable);
        drawable.addState(stateUnSelectArr, unSelectDrawable);
        return  drawable;
    }

    public StateListDrawable getPressSelector(Drawable selectDrawable, Drawable unSelectDrawable){
        StateListDrawable drawable = new StateListDrawable();
        int[] stateSelectArr = new int[]{android.R.attr.state_pressed, };
        int[] stateUnSelectArr = new int[]{-android.R.attr.state_pressed, };
        drawable.addState(stateSelectArr, selectDrawable);
        drawable.addState(stateUnSelectArr, unSelectDrawable);
        return  drawable;
    }

    public ColorStateList getColorStateListSelector(int[] stateSelectArr, int selectColor, int[] stateUnSelectArr, int unSelectColor){
        ColorStateList stateColor = new ColorStateList(new int[][] {stateSelectArr,stateUnSelectArr},
                new int[] {selectColor , unSelectColor});
        return  stateColor;
    }

    public ColorStateList getColorStateCheckSelector(int selectColor, int unSelectColor){
        int[] stateSelectArr = new int[]{android.R.attr.state_checked, };
        int[] stateUnSelectArr = new int[]{-android.R.attr.state_checked, };
        ColorStateList stateColor = new ColorStateList(new int[][] {stateSelectArr,stateUnSelectArr},
                new int[] {selectColor , unSelectColor});
        return  stateColor;
    }

}
